<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>


  <div id="box">
    {{text}}
    <br>
    <input type="text" v-model="spoken">
    <button @click="send">发送</button>
    <audio :src="url" controls autoplay></audio>
  </div>

  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  <script>


    new Vue({
      el: '#box',
      data: {
        text: 'hello Vue',
        spoken: '',
        url: ''
      },
      methods: {
        async send() {
          const res = await axios({
            url: 'http://ajax-api.itheima.net/api/robot?spoken=' + this.spoken,
          })
          console.log(res.data.data.info.text);

          const res1 = await axios({
            url: 'http://ajax-base-api-t.itheima.net/api/synthesize?text=' + res.data.data.info.text,
          })
          console.log(res1.data.voiceUrl);
          this.url = res1.data.voiceUrl

        }
      }
    })

  </script>

</body>

</html>